package leetcode_200;

public class SingleNumberII_137_ {

	public static void main(String[] args) {
		SingleNumberII_137_ test=new SingleNumberII_137_();
		System.out.println(test.singleNumber(new int[] {2,2,3,2}));

	}
	
	public int singleNumber(int[] nums) {
        int[] count = new int[32];
        int result = 0;

        for (int i = 0; i < 32; i++) {
            for (int n : nums) {
                // 统计第i位的1的个数
                if (((n >> i) & 1) == 1) {
                    count[i]++;
                }
            }
            //做或运算   第几位除以3 余下就是单独的位数 再进行还原
            result += (count[i] % 3) << i;
        }

        return result;
    }

}
